unit selecttestconfig;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ComCtrls, SelectTest;

type
  TFormSelectTestConfig = class(TForm)
    buttonOK: TButton;
    buttonCancel: TButton;
    pagecontrol: TPageControl;
    tabsheetGeneral: TTabSheet;
    labelLoopCount: TLabel;
    editLoopCount: TEdit;
    tabsheetSQL: TTabSheet;
    memoSQL: TMemo;
    checkboxGetValues: TCheckBox;
    checkboxUnprepareOnClose: TCheckBox;
    labelValueReadCount: TLabel;
    editValueReadCount: TEdit;
  public
    class procedure ConfigureTest(Test: TSelectTest);
  private
    FTest: TSelectTest;
    procedure TestToForm;
    procedure TestFromForm;
  end;

implementation

{$R *.dfm}

{ TFormSelectTestConfig }

class procedure TFormSelectTestConfig.ConfigureTest(Test: TSelectTest);
begin
  with TFormSelectTestConfig.Create(nil) do
    try
      FTest := Test;
      TestToForm;
      if ShowModal = mrOK then
        TestFromForm;
    finally
      Free;
    end;
end;

procedure TFormSelectTestConfig.TestFromForm;
begin
  FTest.Attempts := StrToInt(editLoopCount.Text);
  FTest.ValueReadCount := StrToInt(editValueReadCount.Text);
  FTest.ReadFieldValues := checkboxGetValues.Checked;
  FTest.UnprepareOnClose := checkboxUnprepareOnClose.Checked;
  FTest.SQL.Assign(memoSQL.Lines);
end;

procedure TFormSelectTestConfig.TestToForm;
begin
  editLoopCount.Text := IntToStr(FTest.Attempts);
  editValueReadCount.Text := IntToStr(FTest.ValueReadCount);
  checkboxGetValues.Checked := FTest.ReadFieldValues;
  checkboxUnprepareOnClose.Checked := FTest.UnprepareOnClose;
  memoSQL.Lines.Assign(FTest.SQL);
end;

end.
